package com.gugu.procedure.controller;


import com.gugu.procedure.bean.CustInfo;
import com.gugu.procedure.common.HttpServletRequestUtils;
import com.gugu.procedure.common.MessageResult;
import com.gugu.procedure.service.CustInfoService;
import com.gugu.procedure.util.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = {"客户信息"})
@RequestMapping("custInfo")
public class CustInfoController {

    @Autowired
    private CustInfoService custInfoService;
    @Autowired
    private HttpServletRequestUtils httpServletRequestUtils;


    @GetMapping("page")
    @ApiOperation(value = "分页查询")
    public MessageResult page(String custNo, int pageNo, int pageSize) {
        return custInfoService.page(custNo, pageNo, pageSize);
    }


    @PostMapping("addOrUpdate")
    @ApiOperation(value = "新增或者修改")
    public MessageResult delete(@RequestBody CustInfo custInfo) {
        custInfo.setCreateTime(DateUtil.getFormatedDateTime());
        custInfoService.save(custInfo);
        return MessageResult.success();
    }

    @GetMapping("delete")
    @ApiOperation(value = "删除")
    public MessageResult delete(String custNo) {
        custInfoService.deleteByCustNo(custNo);
        return MessageResult.success();
    }

}
